<template>
  <div class="container">
    <!-- 我的 头部-->
    <div class="header padding-24 space-between">
      <div class="h-back" @click="goBack">
        <img :src="back" alt />
      </div>
      <div class="title">{{title}}</div>
      <div class="h-right">
        <img :src="play" alt />
      </div>
    </div>
    <!-- 头部选项卡 -->
    <div class="top-card">
      <div class="left">
        <img :src="musicMes.background" alt />
      </div>
      <div class="right">
        <div class="song-name fs-32">单曲《{{musicMes.music_name}}》</div>
        <div class="price fs-32">¥{{musicMes.royalty}}</div>
        <div class="singer-name fs-24">歌手：{{musicMes.singer_name}}</div>
        <div class="album-name fs-24">专辑：{{musicMes.music_list_name}}</div>
      </div>
    </div>
    <!-- 商品介绍 -->
    <div class="introduce">
      <div class="title">
        <div class="text fs-32">商品介绍</div>
      </div>
      <div class="main">
        <div class="top fs-28">
          <p>温馨提示：</p>
          <p>·目前仅会员和部分数字专辑内歌曲支持单曲购买：</p>
          <p>·已购买的单曲可在会员中查看</p>
        </div>
        <div class="explain fs-28">
          <p>购买说明：</p>
          <p>·单曲一经购买不支持退款</p>
          <p>·自购买之时起5分钟内生效</p>
          <p>·单曲一经购买不支持退款</p>
          <p>·自购买之时起5分钟内生效·单曲一经购买不支持退款</p>
          <p>·自购买之时起5分钟内生效·单曲一经购买不支持退款</p>
          <p>·自购买之时起5分钟内生效</p>
        </div>
      </div>
    </div>
    <!-- 底部按钮 -->
    <div class="bottom fs-32" @click="toBuy">立即购买</div>
    <payModel v-if="wantpay" :musicId="music_id" :totalPrice="musicMes.royalty" :status="1" :wantpay="wantpay" @fn="getPayStatus"></payModel>
  </div>
</template>

<script>
export default {
  name: "single-buy",
  data() {
    return {
      title: "单曲购买",
      back: require("@/assets/index/back-mine.png"),
      play: require("@/assets/index/play-mine.png"),
      question: require("@/assets/index/question.png"),
      activeIndex: 0,
      music_id: null,
      musicMes: {},
      orderNum:null,//订单号
      wantpay:false,//是否去支付
      totalPrice:null
    };
  },
  components: {},
  methods: {
    // 立即购买 打开选择支付方式模态框
    toBuy() {
      this.wantpay = true;
    },
    // 获取支付模态框的状态
    getPayStatus(e){
      this.wantpay = e;
    },
    // 返回上一页
    goBack() {
      this.$router.go(-1);
    },
    // 选择开通会员类型
    checkType(count) {
      this.activeIndex = count;
    },
    // 获取单曲购买信息
    getSingleMes() {
      const url = this.$host1 + `home/vip/musicMsg?music_id=` + this.music_id;
      var params = {};
      this.$axios
        .get(url)
        .then(res => {
          console.log(res.data, "---res.data--获取单曲信息");
          if (res.data.code == 200) {
            let data = res.data.data;
            this.musicMes = data;
            this.totalPrice = this.musicMes.royalty/1;
          } else if (res.data.code == 0) {
            this.AlertWin(res.data.message);
            this.$router.push({ path: "/login" });
          } else {
            this.AlertWin(res.data.message);
          }
        })
        .catch(err => {
          console.log(err, "err-----");
        });
    }
  },
  created() {
    this.music_id = this.$route.query.id/1;
    this.getSingleMes();
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.container {
  height: 100vh;
  padding-top: 1rem;
  box-sizing: border-box;
  background-color: #fff;
  // 头部设置
  .header {
    .background {
      background-color: #f8f8f8;
    }
    .h-back {
      width: 0.15rem;
      height: 0.26rem;
      img {
        width: 100%;
      }
    }
    .title {
      font-size: 0.36rem;
      font-weight: bold;
      color: #444444;
    }
    .h-right {
      width: 0.38rem;
      height: 0.5rem;
      img {
        display: inline-block;
        width: 100%;
      }
    }
  }
  // 头部选项卡
  .top-card {
    display: flex;
    padding: 0.35rem 0.27rem;
    box-sizing: border-box;
    border-bottom: 0.01rem solid #e9e9e9;
    background-color: #fff;
    .left {
      img {
        width: 1.89rem;
        height: 1.89rem;
        margin-right: 0.31rem;
      }
    }
    .right {
      .song-name {
        font-weight: bold;
        color: rgba(68, 68, 68, 1);
        margin-bottom: 0.21rem;
      }
      .price {
        font-weight: bold;
        color: rgba(252, 88, 89, 1);
        margin-bottom: 0.2rem;
      }
      .singer-name,
      .album-name {
        font-weight: 500;
        color: rgba(153, 153, 153, 1);
      }
    }
  }
  // 商品介绍部分
  .introduce {
    padding: 0.4rem 0.27rem 0 0.27rem;
    .title {
      border-left: 0.09rem solid #fc5859;
      padding-left: 0.2rem;
      box-sizing: border-box;
      margin-bottom: 0.35rem;
      .text {
        font-weight: bold;
        color: rgba(68, 68, 68, 1);
      }
    }
    .main {
      .top,
      .explain {
        font-weight: 500;
        color: rgba(102, 102, 102, 1);
        line-height: 0.44rem;
      }
      .top {
        margin-bottom: 0.4rem;
      }
    }
  }
  // 底部按钮
  .bottom {
    width: 7.02rem;
    height: 0.9rem;
    text-align: center;
    line-height: 0.9rem;
    background: rgba(84, 4, 121, 1);
    border-radius: 0.45rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 1);
    position: fixed;
    left: 50%;
    bottom: 0.16rem;
    transform: translate(-50%);
  }
}
</style>
